<!--  -->
<template>
  <el-container>
    <el-main>
      <div class="main">
        <div class="back-bar-box mb-30">
          <div class="btn-back" @click="this.$router.go(-1)">
            <i class="el-icon-back"></i> 返回
          </div>
          <div class="line"></div>
          <div class="name">添加课时</div>
        </div>
        <div class="tabs">
          <el-row>
            <el-col :span="24">
              <el-tabs v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="基础信息" name="first">
                  <div class="form">
                    <el-form
                      :model="ruleForm"
                      :rules="rules"
                      ref="ruleForm"
                      label-width="100px"
                      class="demo-ruleForm"
                    >
                      <el-form-item label="上课课时" prop="name">
                        <el-button type="primary">上传视频</el-button>
                      </el-form-item>

                      <el-form-item label="课时名称" prop="name">
                        <el-input v-model="ruleForm.name"></el-input>
                      </el-form-item>

                      <el-form-item label="课时时长" prop="name">
                        <el-input-number
                          v-model="num"
                          @change="handleChange"
                          :min="1"
                          :max="10"
                          label="描述文字"
                        ></el-input-number
                        ><span class="time">时</span>
                        <el-input-number
                          v-model="num"
                          @change="handleChange"
                          :min="1"
                          :max="10"
                          label="描述文字"
                        ></el-input-number
                        ><span class="time">分</span>
                        <el-input-number
                          v-model="num"
                          @change="handleChange"
                          :min="1"
                          :max="10"
                          label="描述文字"
                        ></el-input-number
                        ><span class="time">秒</span>
                        <p class="tip" style="line-height: 40px;">
                          <i class="el-icon-info"></i>
                          <span>后台会根据课时时长统计学员学习进度</span>
                        </p>
                      </el-form-item>

                      <el-form-item label="可试看时长" prop="num">
                        <el-input-number
                          v-model="num"
                          @change="handleChange"
                          :min="1"
                          :max="10"
                          label="描述文字"
                        ></el-input-number
                        ><span class="time">时</span>
                        <el-input-number
                          v-model="num"
                          @change="handleChange"
                          :min="1"
                          :max="10"
                          label="描述文字"
                        ></el-input-number
                        ><span class="time">分</span>
                        <el-input-number
                          v-model="num"
                          @change="handleChange"
                          :min="1"
                          :max="10"
                          label="描述文字"
                        ></el-input-number
                        ><span class="time">秒</span>
                        <p class="tip" style="line-height: 40px;">
                          <i class="el-icon-info"></i>
                          <span>定义课时免费试看时长吸引更多学员试看</span>
                        </p>
                      </el-form-item>

                      <el-form-item label="所属章节" prop="region">
                        <el-select
                          v-model="ruleForm.region"
                          placeholder="请选择章节"
                        >
                          <el-option
                            label="区域一"
                            value="shanghai"
                          ></el-option>
                          <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                        <el-link type="primary" class="chapter"
                          >章节管理</el-link
                        >
                      </el-form-item>

                      <el-form-item label="上架时间" required>
                        <el-date-picker
                          v-model="ruleForm.date1"
                          type="datetime"
                          placeholder="选择日期时间"
                        >
                        </el-date-picker>
                        <p class="tip">
                          <i class="el-icon-info"></i>
                          <span>上架时间越早，课时排序越靠前</span>
                        </p>
                      </el-form-item>

                      <el-form-item>
                        <el-button
                          type="primary"
                          @click="submitForm('ruleForm')"
                          >保存</el-button
                        >
                        <el-button @click="resetForm('ruleForm')"
                          >取消</el-button
                        >
                      </el-form-item>
                    </el-form>
                  </div>
                </el-tab-pane>
                <el-tab-pane label="可选信息" name="second">
                  <div class="form-select">
                    <el-form
                      :model="ruleForm"
                      :rules="rules"
                      ref="ruleForm"
                      label-width="100px"
                      class="demo-ruleForm"
                    >
                      <el-form-item label="禁止快进播放" prop="delivery">
                        <el-switch v-model="ruleForm.delivery"></el-switch>
                        <p class="tip">
                          <i class="el-icon-info"></i>
                          <span>定义课时免费试看时长吸引更多学员试看</span>
                        </p>
                      </el-form-item>

                      <el-form-item label="隐藏课时" prop="delivery">
                        <el-switch v-model="ruleForm.delivery"></el-switch>
                        <p class="tip">
                          <i class="el-icon-info"></i>
                          <span>定义课时免费试看时长吸引更多学员试看</span>
                        </p>
                      </el-form-item>

                      <el-form-item label="阿里云视频文件ID">
                        <el-input
                          v-model="ruleForm.name"
                          placeholder="阿里云视频文件ID"
                        ></el-input>
                      </el-form-item>

                      <el-form-item label="腾讯云视频文件ID">
                        <el-input
                          v-model="ruleForm.name"
                          placeholder="腾讯云视频文件ID"
                        ></el-input>
                      </el-form-item>

                      <el-form-item label="视频URL">
                        <el-input
                          v-model="ruleForm.name"
                          placeholder="视频URL"
                        ></el-input>
                      </el-form-item>
                    </el-form>
                  </div>
                </el-tab-pane>
              </el-tabs>
            </el-col>
          </el-row>
        </div>
      </div>
    </el-main>
  </el-container>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      activeName: "first",
      ruleForm: {
        name: "",
        region: "",
        date1: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
        num: 0,
      },
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "change" },
        ],
        date1: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
        date2: [
          {
            type: "date",
            required: true,
            message: "请选择时间",
            trigger: "change",
          },
        ],
        type: [
          {
            type: "array",
            required: true,
            message: "请至少选择一个活动性质",
            trigger: "change",
          },
        ],
        resource: [
          { required: true, message: "请选择活动资源", trigger: "change" },
        ],
        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }],
      },
      num: 0,
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    // goBack: function () {
    //   this.$router.go(-1);
    // },
    handleClick(tab, event) {
      // console.log(tab, event);
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      // this.$refs[formName].resetFields();
    },
    handleChange(value) {
      // console.log(value);
    },
  },

  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
};
</script>
<style lang='scss'  scoped>
.el-container {
  height: 100%;
  text-align: center;
}
.el-main {
  background-color: #f1f2f9;
  padding: 20px 5px 20px 20px;
  .main {
    width: 100%;
    height: auto;
    float: left;
    background-color: #fff;
    box-sizing: border-box;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 90px;
    box-shadow: 0 2px 4px 0 hsl(0deg 0% 40% / 5%);
    min-width: 1180px;
    .back-bar-box {
      display: flex;
      align-items: center;
      width: 100%;
      height: auto;
      float: left;
      margin-bottom: 30px;
      .btn-back {
        font-size: 14px;
        font-weight: 400;
        color: #333;
        cursor: pointer;
        i.el-icon-back {
          font-family: element-icons !important;
          //   speak: none;
          font-style: normal;
          font-weight: 400;
          font-variant: normal;
          text-transform: none;
          line-height: 1;
          vertical-align: baseline;
          display: inline-block;
          -webkit-font-smoothing: antialiased;
        }
      }

      .line {
        width: 1px;
        height: 14px;
        background-color: #d8d8d8;
        margin-right: 15px;
        margin-left: 15px;
      }

      .name {
        font-size: 14px;
        font-weight: 600;
        color: #333;
      }
    }
    .tabs {
      ::v-deep .el-tabs__header {
        display: flex;
        justify-content: center;
        margin-bottom: 30px;
      }
    }
    .form {
      .el-input {
        width: 300px;
      }
      ::v-deep .el-form-item__content {
        text-align: left;
        margin-left: 200px !important;
      }
      ::v-deep .el-form-item__content {
        display: flex;
        align-items: center;
      }
      .time {
        margin: 0 10px;
        display: inline-block;
        height: 30px;
        line-height: 30px;
        font-size: 14px;
        color: rgba(0, 0, 0, 0.5);
      }
      .tip {
        margin-left: 10px;
        font-size: 14px;
        color: rgba(0, 0, 0, 0.5);
        span {
          margin-left: 5px;
        }
      }
      ::v-deep .el-form-item__label {
        width: 200px !important;
      }
      .el-input-number {
        width: 130px;
        line-height: 30px;
      }
      .el-select {
        width: 300px;
      }
      ::v-deep .el-input--small .el-input__inner {
        height: 32px;
        line-height: 32px;
      }
      ::v-deep .el-input-number .el-input__inner {
        height: 32px;
        line-height: 32px;
      }
      .chapter {
        margin-left: 10px;
      }
      .el-form-item:last-child {
        position: fixed;
        bottom: -23px;
        left: 200px;
        right: 0;
        z-index: 2000;
        box-sizing: border-box;
        padding-top: 20px;
        padding-bottom: 20px;
        padding-left: 20px;
        background-color: #fff;
        display: flex;
        box-shadow: 0 -2px 4px 0 hsl(0deg 0% 40% / 5%);
      }
      ::v-deep .el-form-item:last-child .el-form-item__content {
        margin-left: 0px !important;
      }
    }
    .form-select {
      ::v-deep .el-form-item__content {
        text-align: left;
        margin-left: 200px !important;
        display: flex;
        align-items: center;
      }

      .tip {
        margin-left: 10px;
        font-size: 14px;
        color: rgba(0, 0, 0, 0.5);
        span {
          margin-left: 5px;
        }
      }
      ::v-deep .el-form-item__label {
        width: 200px !important;
      }
      .el-input {
        width: 300px;
      }
    }
  }
}
</style>